package com.demo2do.fms.queue.dao.order;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.demo2do.core.persistence.GenericDaoSupport;
import com.demo2do.core.persistence.GenericJdbcSupport;
import com.demo2do.fms.entity.business.balance.OtherFee;

/**
 *
 * @author Ark
 *
 */
@Repository("otherFeeDaoSupport")
public class OtherFeeDaoSupport {
    
    @Autowired
    private GenericJdbcSupport genericJdbcSupport;
    
    @Autowired
    private GenericDaoSupport genericDaoSupport;
    
    /**
     * load other_fee by other_fee_type_id, dispatch_order_id and anji_set
     * 
     * @param otherFeeTypeId
     * @param dispatchOrderId
     * @param anjiSet
     * @return
     */
    public OtherFee load(Long otherFeeTypeId, Long dispatchOrderId, Boolean anjiSet) {
        
        String sentence = "FROM OtherFee f WHERE f.otherFeeTypeId = :otherFeeTypeId AND f.dispatchOrderId = :dispatchOrderId AND f.anjiSet = :anjiSet";
        
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("otherFeeTypeId", otherFeeTypeId);
        parameters.put("dispatchOrderId", dispatchOrderId);
        parameters.put("anjiSet", anjiSet);
        
        return genericDaoSupport.searchForObject(sentence, parameters, OtherFee.class);
        
        
    }
    
    /**
     * 获取其他费用(FC_GET_OTHER_FEE)
     * 
     * @param dispatchOrderId
     * @return
     */
    public Object getOtherFee(Long dispatchOrderId) {
        
        String sentence = "SELECT FC_GET_OTHER_FEE(:dispatchOrderId) AS fee FROM DUAL";
        
        Map<String, Object> result = genericJdbcSupport.queryForObject(sentence, "dispatchOrderId", dispatchOrderId);
        return result.get("fee");
        
    }
    
}
